package com.platform.modular.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yifei.han
 * @version 1.0
 * @className WebMvcConfig
 * @description
 * @date 2022/3/12
 */
@Lazy
@Component
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    private AppIdHanlderInterceptor appIdHanlderInterceptor;

    @Autowired
    private TokenHandlerInterceptor tokenHandlerInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(appIdHanlderInterceptor).addPathPatterns("/**");

        List<String> tokenCheckExcludePath = new ArrayList<>();
        tokenCheckExcludePath.add("miniprogram/login/**");
        registry.addInterceptor(tokenHandlerInterceptor).addPathPatterns("/**").excludePathPatterns();
    }


}
